package com.example.keli.ui.my.vote;

import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.example.keli.R;
import com.example.keli.base.BaseActivity;
import com.example.keli.base.utils.DensityUtil;
import com.example.keli.ui.my.adapter.LoveDetailAdapter;
import com.example.keli.ui.my.adapter.VoteDetailAdapter;
import com.example.keli.ui.my.model.LoveReciveBean;
import com.example.keli.ui.my.model.VoteReceiveBean;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class VoteDetailActivity extends BaseActivity {


    @BindView(R.id.recycler_vote_detail)
    RecyclerView mRecycler;
    @BindView(R.id.tv_vote_title)
    TextView tvVoteTitle;

    private List<VoteReceiveBean.DataBean.UserInfoBean> mDataList;
    private VoteDetailAdapter mAdapter;

    @Override
    protected int layoutId() {
        return R.layout.activity_vote_detail;
    }

    @Override
    protected void bindData() {
//        setTitle("投票详情");
        abTitle.setText("投票详情");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mDataList = new ArrayList<>();
        VoteReceiveBean.DataBean dataBean = (VoteReceiveBean.DataBean) getIntent().getSerializableExtra("recive_vote");
        if (dataBean != null){
            mDataList.addAll(dataBean.getUserInfo());
            mAdapter = new VoteDetailAdapter(mDataList, this);
            mRecycler.setLayoutManager(new LinearLayoutManager(this));
            mRecycler.setAdapter(mAdapter);
            mRecycler.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this)
                    .color(ContextCompat.getColor(this, R.color.divider_line))
                    .size(DensityUtil.dip2px(this, 1))
                    .build());
            tvVoteTitle.setText(dataBean.getTitle());
        }
    }

}
